package util

import "time"

//订单查询时间
const (
	InAllTime         = -1 //全部查询
	InLastOneWeek     = 1  //最近一个月订单
	InLastThreeMonths = 2  //最近三个月订单
	InLastSixMonths   = 3  //最近六个月订单
)

//订单交易状态--第三方平台支付状态保持一致
const (
	TradeSuccess  = "SUCCESS"    //支付成功
	TradePaying   = "USERPAYING" //用户支付中（付款码支付）
	TradeNoPay    = "NOTPAY"     //未支付
	TradeClosed   = "CLOSED"     //已关闭
	TradeRevoked  = "REVOKED"    //已撤销(已取消支付)
	TradePayError = "PAYERROR"   //支付失败(其他原因，如银行返回失败)

	//OrderLiftTime 系统订单存活时间
	OrderLiftTime = time.Minute * 10
)

//订单全部状态
var OrderAllStatus = []string{TradeNoPay, TradePaying, TradeSuccess, TradeClosed, TradePayError, TradeRevoked}

//订单未支付状态
var OrderInNoPay = []string{TradeNoPay, TradePaying}

//订单已完成状态
var OrderDone = []string{TradeSuccess}

//订单已关闭状态
var OrderClosed = []string{TradeClosed, TradePayError, TradeRevoked}

//不同状态对应的查询标志位
const (
	OrderAllStatusFlag = -1
	OrderInNoPayFlag   = 1
	OrderClosedFlag    = 2
	OrderDoneFlag      = 3
)

var ValidOrderStatusFlag = []int{OrderAllStatusFlag, OrderInNoPayFlag, OrderDoneFlag, OrderClosedFlag}

func GetOrderStatusArray(flag int) []string {
	if flag == OrderAllStatusFlag {
		return OrderAllStatus
	} else if flag == OrderInNoPayFlag {
		return OrderInNoPay
	} else if flag == OrderDoneFlag {
		return OrderDone
	} else if flag == OrderClosedFlag {
		return OrderClosed
	} else {
		return nil
	}
}
